/*FCApr9JgjfAoCk3vK7TNA8WZHN++JJB9vAtzo+Iwuc+cbrjE5nC/rtU4FB0PIL6T*/
import { assetAppcode, assetTransferPageCode, assetTransferSearch, assetTransferHead } from '../constants';
import { linkCard } from './buttonClick';

import ampub from 'ampub';
import fa from 'fa';

const { commonConst: { CommonKeys: { IBusiRoleConst } } } = ampub;

const { fa_components: { ReferFilter: { addSearchAreaReferFilter } } } = fa;

export default function(props) {
	props.createUIDom(
		{
			pagecode: assetTransferPageCode,
			appcode: assetAppcode
		},
		(data) => {
			if (data) {
				if (data.template) {
					let meta = data.template;
					meta = modifierMeta.call(this, props, meta);
					props.meta.addMeta(meta);
				}
			}
		}
	);
}
function modifierMeta(props, meta) {
	let ListConfig = {
		searchId: assetTransferSearch,
		specialFields: {
            // pk_transactor经办人	bodyvos.pk_usedept使用部门 bodyvos.pk_mandept管理部门 bodyvos.pk_mandept_v管理部门 bodyvos.pk_assetuser使用人
            // 申请单位
			pk_applyorg: {
				data: [
					{
						fields: [ 'pk_org' ],
						returnName: 'pk_org'
					}
				]
			},
            // 申请部门
			pk_applydapt: {
				orgMulti: 'pk_org',
				data: [
					{
						fields: [ 'pk_applyorg', 'pk_org' ],
						returnName: 'pk_org'
					},
					{
						returnConst: IBusiRoleConst.ASSETORG,
						returnName: 'busifuncode'
					}
				]
			},

            // 申请人
			pk_proposer: {
				orgMulti: 'pk_org',
				data: [
					{
						fields: [ 'pk_applyorg' ],
						returnName: 'pk_org'
					},
					{
						returnConst: IBusiRoleConst.ASSETORG,
						returnName: 'busifuncode'
					}
				]
			},
            // 经办人
			pk_transactor: {
				orgMulti: 'pk_org',
				data: [
					{
						fields: [ 'pk_org' ],
						returnName: 'pk_org'
					},
					{
						returnConst: IBusiRoleConst.ASSETORG,
						returnName: 'busifuncode'
					}
				]
			},
            // 使用部门
			pk_usedept: {
                isRunWithChildren: true, //是否执行时包含下级
			    defaultRunWithChildren: true, //是否默认勾选执行时包含下级
				orgMulti: 'pk_org',
				data: [
					{
						fields: [ 'bodyvos.pk_equiporg', 'pk_org' ],
						returnName: 'pk_org'
					},
					{
						returnConst: IBusiRoleConst.ASSETORG,
						returnName: 'busifuncode'
					}
				]
			},
            // 管理部门
			pk_mandept: {
                isRunWithChildren: true, //是否执行时包含下级
			    defaultRunWithChildren: true, //是否默认勾选执行时包含下级
				orgMulti: 'pk_org',
				data: [
					{
						fields: [ 'bodyvos.pk_ownerorg', 'pk_org' ],
						returnName: 'pk_org'
					},
					{
						returnConst: IBusiRoleConst.ASSETORG,
						returnName: 'busifuncode'
					}
				]
			},
            // 管理部门
			pk_mandept_v: {
                isRunWithChildren: true, //是否执行时包含下级
			    defaultRunWithChildren: true, //是否默认勾选执行时包含下级
				orgMulti: 'pk_org',
				data: [
					{
						fields: [ 'bodyvos.pk_ownerorg', 'pk_org' ],
						returnName: 'pk_org'
					},
					{
						returnConst: IBusiRoleConst.ASSETORG,
						returnName: 'busifuncode'
					}
				]
			},
            // 使用人
			pk_assetuser: {
                isRunWithChildren: true, //是否执行时包含下级
			    defaultRunWithChildren: true, //是否默认勾选执行时包含下级
				orgMulti: 'pk_org',
				data: [
					{
						fields: [ 'bodyvos.pk_equiporg', 'pk_org' ],
						returnName: 'pk_org'
					},
					{
						returnConst: IBusiRoleConst.ASSETORG,
						returnName: 'busifuncode'
					}
				]
			}
		}
	};
	// 查询条件过滤
	addSearchAreaReferFilter.call(this, props, meta, ListConfig);

	//增加超链接
	meta[assetTransferHead].items = meta[assetTransferHead].items.map((item, key) => {
		if (item.attrcode == 'bill_code') {
			item.render = (text, record, index) => {
				let transType = record.transi_type.value;
				return (
					<div class="simple-table-td">
						<span
							className="code-detail-link"
							onClick={() => {
								linkCard.call(this, props, record, 'pk_newasset', transType);
							}}
						>
							{record && record.bill_code && record.bill_code.value}
						</span>
					</div>
				);
			};
		}

		return item;
	});
	return meta;
}

/*FCApr9JgjfAoCk3vK7TNA8WZHN++JJB9vAtzo+Iwuc+cbrjE5nC/rtU4FB0PIL6T*/